jQuery success:function{} issue

Posted by ufw on Stack Overflow See other posts from Stack Overflow or by ufw
Published on 2010-05-02T15:39:47Z Indexed on 2010/05/02 15:48 UTC
Read the original article Hit count: 214

Filed under:
|
|

I have several 'select' elements on the page. When I choose some of options, the ajax request is being sent to server and the element adjacent to this 'select' must be updated with response value. I expected the following code to be working:

$(".vars").live("change", function() { //selected something in <select> list
    $.ajax({
        type: "POST",
        url "someurl.php",
        data: {somedata},
        success: function(html) {
            $this.next().html(html); //this does not update .next() element.
        }
    });
});

If I replace

$(this).next().html(html);

with

alert(html);

I can see the ajax request was successful. Moreover, it works only if there is only one 'select' on the page, otherwise the empty pop-up appears.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX